// document.write("new a model!")
// $.get("json/test_data.json",function(data){
//     console.log(data);
//     // console.log(data);
//   // 画图
//   var myChart = echarts.init(document.getElementById("main"));
//   var option = {
//     series: [
//       {
//         type: "pie",
//         data:data.data_pie,
//       },
//     ],
//   };
//   myChart.setOption(option);
// });

$.get("../json/work.csv",function (temp){
  // console.log(typeof(temp));
  temp = temp.split('\r\n');
  // console.log(temp);
  var show_value=[];
  for(var i=0;i<temp.length;i++){
    var data1=temp[i].split(',');
    show_value.push(data1);
    // console.log(data1);
  }
  // console.log(show_value[0][1]);
  var name_company=[];
  var price_month=[];
  var number_employee=[];
  for(var i=1;i<show_value.length;i++){
    name_company.push(show_value[i][0])
    price_month.push(show_value[i][2])
    number_employee.push(show_value[i][6]);
  }

  var myChart = echarts.init(document.getElementById("main"));
  var option = {
    title:{
      text:'就业情况',
      left:'center',
      subtext:'月薪和招聘人数',
    },
    legend: {
      right: '10%',
    },
    grid: [{
      left: '30%',
      right: '10%',
    },],
    visualMap: [{
      type:'continuous',
      seriesIndex: 0,
      top: 'middle',
      left: '15%',
      min: 5000,
      max: 23000,
      inRange: {
        color: ['#f3715c','#50b7c1','#fdb933'],
      },
    },{
      type:'continuous',
      seriesIndex: 1,
      right: 'right',
      top: 'middle',
      min: 1,
      max: 30,
      inRange: {
        color: ['#ad8b3d','#65c294','#9b95c9'],
      },
    }],
    toolbox: {
      orient: 'vertical',
      feature: {
        dataView: {},
        restore: {},
        saveAsImage: {},
      },
    },
    dataZoom:[{
      type:'slider',
      backgroundColor:'white',
    },{
      type:'inside',
    }],
    xAxis:[{
      name:show_value[0][0],
      type:'category',
      data:name_company,
      gridIndex: 0,
    }],
    yAxis:[{
      name:show_value[0][2],
      min:1,
      max:23000,
      gridIndex: 0,
    },
    {
      name:show_value[0][6],
      min:1,
      max:100,
    }],
    series: [
      {
        type: "line",
        name:show_value[0][2],
        data:price_month,
        yAxisIndex:0,
      },
      {
        type: 'bar',
        name:show_value[0][6],
        data:number_employee,
        yAxisIndex:1,
      },
    ],
  };
  myChart.setOption(option);
});